package org.pjlib.common;

import android.animation.ObjectAnimator;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.blankj.utilcode.util.StringUtils;

import org.pjlib.Logs;
import org.pjlib.R;

/**
 * Created by ws on 2019/04/15.
 */
public class LoadDialog extends Dialog {

    private String text;

    public LoadDialog(Context context) {
        super(context, R.style.dialog);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_load);
        if (!StringUtils.isEmpty(text)) {
            TextView   tv_title = findViewById(R.id.tv_title);
            Logs.i(this, "--" + tv_title);
            tv_title.setText(text);
        }
        View view=findViewById(R.id.iv_load);
        ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(view,"rotation",360f);
        objectAnimator.setDuration(2000);
        objectAnimator.setRepeatCount(-1);
        objectAnimator.start();
    }

    public void setTitle(String text) {
        this.text = text;
    }
}
